package view;

import processing.core.PApplet;
import processing.core.PFont;

///////////////////
//TOOLTIP VIEW
//UI Tooltips are used for displaying a helpful hint next to the mouse when it rests over an object for long enough.
public class V_Tooltip extends V_DisplayObject {
	private String name;
	private PFont Font;
	private int pad = 3;
	private int fontSize = 10;
	private int alphaVal = 230;
	private float flipX = 0;
	private float flipY = 0;

	private int textColor; 
	
	private PApplet parent;

	public V_Tooltip(PApplet p) {
		name = "temp";
		parent = p;
		Font = p.createFont("Verdana-10", fontSize);
		textColor = p.color(0, 0, 0, alphaVal);
		bgColor = p.color(255, 255, 150, alphaVal - 10);
	}

	public void display(PApplet p) {
		if (visible) {
			p.stroke(0, 0, 0, alphaVal - 200);
			p.fill(bgColor);
			p.rect(xLoc - pad + flipX, yLoc - fontSize - pad + flipY, xSize,
					ySize);
			p.fill(textColor);
			p.textFont(Font);
			p.text(name, xLoc + flipX, yLoc + flipY);
		}
	}

	public void setName(String n) {
		name = n;
		// adjust the xSize and ySize variables:
		parent.textFont(Font);
		xSize = parent.textWidth(name) + (pad * 2);
		ySize = fontSize + (pad * 2);
	}

	public String getText() {
		return name;
	}

	public void setFlip(float x, float y) {
		flipX = x;
		flipY = y;
	}
	
	public PApplet getParent()
	{
		return parent;
	}
}
